package com.lakeworks.web.controller.core;

import com.lakeworks.common.core.controller.BaseController;
import com.lakeworks.common.core.domain.AjaxResult;
import com.lakeworks.common.core.page.TableDataInfo;
import com.lakeworks.domain.status.PostSort;
import com.lakeworks.service.IPostSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 拣货记录Controller
 *
 * @author lake
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/post/sort")
public class PostSortController extends BaseController {
    @Autowired
    private IPostSortService postSortService;

    /**
     * 查询拣货记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PostSort postSort) {
        startPage();
        List<PostSort> list = postSortService.selectPostSortList(postSort);
        return getDataTable(list);
    }

//    /**
//     * 导出拣货记录列表
//     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, PostSort postSort)
//    {
//        List<PostSort> list = postSortService.selectPostSortList(postSort);
//        ExcelUtil<PostSort> util = new ExcelUtil<PostSort>(PostSort.class);
//        util.exportExcel(response, list, "拣货记录数据");
//    }

    /**
     * 获取拣货记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(postSortService.selectPostSortById(id));
    }

    /**
     * 新增拣货记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody PostSort postSort) {
        return toAjax(postSortService.insertPostSort(postSort));
    }

    /**
     * 修改拣货记录
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PostSort postSort) {
        return toAjax(postSortService.updatePostSort(postSort));
    }

    /**
     * 删除拣货记录
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(postSortService.deletePostSortByIds(ids));
    }
}
